﻿@model LoveEat.MODEL.shop

@{

    ViewBag.Title = "店铺编辑";
    int i = 0;
}
@{
    Html.EnableClientValidation();
}
@using System.Web.Mvc.Html

<style type="text/css">
    <!--
    #input1 {
        border: 1px solid #0000FF;
    }

    #btn1 {
        width: 70px;
        height: 21px;
        font-size: 12px;
        padding-top: 3px;
        background: url(83.gif) no-repeat;
        height: 22px;
        border: 0;
    }

    // -->
</style>
<ul class="breadcrumb">
    <li>
        <i class="icon-home"></i>
        <a href="/">
            首页
        </a>
        <i class="icon-angle-right">
        </i>
    </li>
    <li>
        <a href="@Url.Action("Shop", "BusinessManagement")">
            店铺管理
        </a>
        <i class="icon-angle-right">
        </i>
    </li>
    <li>
        <a href="javascript:void(0)">
            编辑面板
        </a>
    </li>
</ul>
<div class="row-fluid">
    <div class="span12">
        <div class="portlet box grey">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-credit-card"></i>
                    新增/编辑系列
                </div>
                <div class="tools">
                    <a href="javascript:;" class="collapse">
                    </a>
                </div>
                <div class="actions">
                    <a>
                    </a>
                </div>
            </div>
            <div class="portlet-body form">

                <form id="signupForm" action="@Request.Url.ToString()" method="post" enctype="multipart/form-data" onsubmit="Compare()" class="form-horizontal" novalidate="novalidate">
                    <div class="control-group">
                        <label class="control-label">
                            店铺名称
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">
                            @Html.HiddenFor(model => model.shop_id)
                            @Html.HiddenFor(model => model.status)
                            @Html.TextBoxFor(model => model.shop_name)
                        </div>
                    </div>
                    <div class="control-group">


                        <label class="control-label">
                            店铺Logo
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">
                            @if (Model.shop_id > 0)
                            {
                                <img src="@Model.shop_icon" width="100" height="100" style=" border:1px solid #808080" />
                                <br />
                            }
                            @Html.TextBoxFor(model => model.shop_icon)
                            <input name="button" type="button" id="btn1" onclick="imageUpLoad.click();" value="浏览文档" />
                            <input type="file" id="imageUpLoad" name="imageUpLoad" onchange="shop_icon.value = this.value" style="display:none">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            联系人
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">
                            @Html.TextBoxFor(model => model.contacts)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            联系电话
                            <span class="required">

                            </span>
                        </label>
                        <div class="controls">
                            @Html.TextBoxFor(model => model.tel)
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            手机
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">
                            @Html.TextBoxFor(model => model.phone)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            地区
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">

                            @Html.DropDownListFor(model => model.provinces_id, ViewBag.provincesList as System.Web.Mvc.SelectList, "请选择省份", new { onChange = "on(this,'city_id')" })
                            @Html.DropDownListFor(model => model.city_id, ViewBag.city_idList as System.Web.Mvc.SelectList, "请选择城市", new { onChange = "on(this,'region_id')" })
                            @Html.DropDownListFor(model => model.region_id, ViewBag.region_idList as System.Web.Mvc.SelectList, "请选择地区", new { onChange = "on(this,'region_id11')" })

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            地址
                            <span class="required">
                                *
                            </span>
                        </label>
                        <div class="controls">
                            @Html.TextBoxFor(model => model.address)
                        </div>
                    </div>

                    <div class="form-actions">
                        <button type="submit" class="btn purple m-wrap">保存</button>
                        @*<a class="btn btn-default m-wrap" href="@Request.Url">返回</a>
                            <button type="button" class="btn btn-default" data-dismiss="modal" onclick="window.location.reload();">
                                取消*@
                     
                        <input type="hidden" name="hidStuatus" value="" />
                        <input type="hidden" name="returnUrl" value="@Request["returnUrl"]" />
                    </div>

                </form>
                <!-- END FORM-->
            </div>
        </div>
    </div>
</div>
<script charset="utf-8" src="~/Content/Scripts/plugins/Editor/kindeditor-min.js"></script>
<script charset="utf-8" src="~/Content/Scripts/plugins/Editor/zh_CN.js"></script>
<script type="text/javascript">
    $().ready(function () {
        $("#signupForm").validate({
            rules: {
                region_id: "required",
                contacts: "required",
                shop_icon: "required",
                phone: { required: true, rangelength: [11, 11], },
                address: "required",
                shop_name: {
                    required: true
                },
                menu_type_id: {
                    required: true,

                }
            },
            messages: {
                region_id: "请选择地区",
                shop_icon: "请添加店铺图片",
                contacts: "请输入联系人姓名",
                phone: { required: "请输入手机号码", rangelength: "手机号码格式不正确" },
                address: "请输入地址",
                shop_name: {
                    required: "请输入店铺名称",

                }

            }
        });




    });
    //function doBan() {
    //    $("#sub").attr("disabled", "disabled");
    //}

    function on(provinces_id, selectBtn) {

        if (provinces_id.value == '' || provinces_id.value == null) {
            $("#city_id").html("<option>请选择</Option>");
            $("#region_id").html("<option value=''>请选择</Option>");
            return false;
        }
        if (provinces_id.value == '请选择') {
            $("#region_id").html("<option value=''>请选择</Option>");
            return false;
        }
        else {
            $.ajax({
                type: "POST",
                url: "/BusinessManagement/Common_areaList",
                data: { ParentId: provinces_id.value },
                dataType: "JSON",
                success: function (data) {

                    if (data != null) {
                        $("#" + selectBtn).empty();
                        $("#" + selectBtn).append("<option value=''>请选择</Option>");
                        for (var i = 0; i < data.length; i++) {

                            $("#" + selectBtn).append("<option value=" + data[i].AreaId + ">" + data[i].AreaName + "</Option>");
                        }
                    }
                    else {
                        $("#" + selectBtn).append("<option value=''>请选择</Option>");
                    }
                    $("signupForm").removeData("validator").removeData("unobtrusiveValidation");
                    $.validator.unobtrusive.parse($("signupForm"));
                }

            });

        }
    }

</script>
